//
//  UIColor+Category.m
//  Teleport
//
//  Created by RLY on 2020/5/14.
//  Copyright © 2020 xxt. All rights reserved.
//

#import "UIColor+Category.h"

@implementation UIColor (Category)

+ (nonnull UIColor *)tj_2FBDF4Color {
    return UIColorMake(0x2FBDF4);
}

+ (nonnull UIColor *)tj_CCCCCCColor {
    return UIColorMake(0xCCCCCC);
}

+ (nonnull UIColor *)tj_1A1A1AColor {
    return UIColorMake(0x1A1A1A);
}

//背景颜色
+ (nonnull UIColor *)tj_101320Color {
    return UIColorMake(0x181A2B);
}

+ (nonnull UIColor *)tj_backgroundColor {
    return UIColorMake(0x15161A);
}

+ (nonnull UIColor *)tj_1D0061Color {
    return UIColorMake(0x1D0061);
}

+ (nonnull UIColor *)tj_F3F2F7Color {
    return UIColorMake(0xF3F2F7);
}

+ (nonnull UIColor *)tj_F7FDFCColor {
    return UIColorMake(0xF7FDFC);
}

+ (nonnull UIColor *)tj_FFF8F1Color {
    return UIColorMake(0xFFF8F1);
}

+ (nonnull UIColor *)tj_23E6FFColor {
    return UIColorMake(0x23E6FF);
}

+ (nonnull UIColor *)tj_00FFFFColor {
    return UIColorMake(0x00FFFF);
}

+ (nonnull UIColor *)tj_9198ADColor {
    return UIColorMake(0x9198AD);
}

+ (nonnull UIColor *)tj_011126Color {
    return UIColorMake(0x011126);
}

+ (nonnull UIColor *)tj_474D5EColor {
    return UIColorMake(0x474D5E);
}

+ (nonnull UIColor *)tj_616A85Color {
    return UIColorMake(0x616A85);
}

+ (nonnull UIColor *)tj_6A6A6AColor {
    return UIColorMake(0x6a6a6a);
}


+ (nonnull UIColor *)tj_F6F3FFColor {
    return UIColorMake(0xF6F3FF);
}

+ (nonnull UIColor *)tj_0099FFColor {
    return UIColorMake(0x0099FF);
}

+ (nonnull UIColor *)tj_00C6FFColor {
    return UIColorMake(0x00C6FF);
}

+ (nonnull UIColor *)tj_navColor {
    return [UIColor whiteColor];
}

+ (nonnull UIColor *)tj_666666Color {
    return UIColorMake(0x666666);
}

+ (nonnull UIColor *)tj_999999Color {
    return UIColorMake(0x999999);
}

+ (nonnull UIColor *)tj_333333Color {
    return UIColorMake(0x333333);
}

+ (nonnull UIColor *)tj_868391Color {
    return UIColorMake(0x868391);
}

+ (nonnull UIColor *)tj_FF5100Color {
    return UIColorMake(0xFF5100);
}

+ (nonnull UIColor *)tj_9D9D9DColor {
    return UIColorMake(0x9D9D9D);
}

+ (nonnull UIColor *)tj_9B9B9BColor {
    return UIColorMake(0x9B9B9B);
}

+ (nonnull UIColor *)tj_mainColor {
    return UIColorMake(0x2978F0);
}

+ (nonnull UIColor *)tj_F5F5F5Color {
    return UIColorMake(0xF5F5F5);
}

+ (nonnull UIColor *)tj_512BEAColor {
    return UIColorMake(0x512BEA);
}

+ (nonnull UIColor *)tj_F6F6F6Color {
    return UIColorMake(0xF6F6F6);
}

+ (nonnull UIColor *)tj_FFFFFFColor {
    return UIColorMake(0xFFFFFF);
}

+ (nonnull UIColor *)tj_EDE6FFColor {
    return UIColorMake(0xEDE6FF);
}

+ (nonnull UIColor *)tj_BEBDCAColor {
    return UIColorMake(0xBEBDCA);
}

+ (nonnull UIColor *)tj_FFA41AColor {
    return UIColorMake(0xFFA41A);
}

+ (nonnull UIColor *)tj_E0421CColor {
    return UIColorMake(0xE0421C);
}

+ (nonnull UIColor *)tj_separatorColor {
    return UIColorMake(0xE0E0E0);
}

+ (nonnull UIColor *)tj_cellSeparatorColor {
    return UIColor.tj_F3F2F7Color;
}

+ (nonnull UIColor *)tj_redColor {
    return UIColorMake(0xFF5A55);
}

+ (nonnull UIColor *)tj_blueColor; {
    return UIColorMake(0x5187EE);
}

+ (nonnull UIColor *)tj_grayColor {
    return UIColor_RGB(237, 237, 237);
}

+ (nonnull UIColor *)tj_8667FEColor {
    return UIColorMake(0x8667FE);
}

+ (nonnull UIColor *)tj_6D4DE7Color {
    return UIColorMake(0x6D4DE7);
}

+ (nonnull UIColor *)tj_3AB197Color {
    return UIColorMake(0x3AB197);
}

+ (nonnull UIColor *)tj_F4654DColor {
    return UIColorMake(0xF4654D);
}

+ (nonnull UIColor *)tj_8B6EFEColor {
    return UIColorMake(0x8B6EFE);
}

+ (nonnull UIColor *)tj_FFEEE6Color {
    return UIColorMake(0xFFEEE6);
}


+ (nonnull UIColor *)tj_8D9298Color {
    return UIColorMake(0x8D9298);
}

+ (UIColor *)tj_blackColor {
    return UIColor.blackColor;
}

+ (UIColor *)tj_disabledColor {
    return [UIColor.whiteColor colorWithAlphaComponent:0.5];
}

+ (nonnull UIColor *)tj_selectCellBackgroundColor {
    return UIColorMake(0xF6F6F6);
}

+ (nonnull UIColor *)tj_topCellBackgroundColor {
    return UIColorMake(0xF6F6F6);
}

+ (nonnull UIColor *)tj_alertMaskColor {
    return [[UIColor blackColor] colorWithAlphaComponent:0.5];
}

+ (nonnull NSArray <UIColor *> *)tj_maskGradientColors {
    return @[[[UIColor blackColor] colorWithAlphaComponent:0.3], [[UIColor blackColor] colorWithAlphaComponent:0]];
}

+ (nonnull UIColor *)tj_tabbarUnSelectColor {
    return UIColor.tj_8D9298Color;
}

+ (nonnull UIColor *)tj_tabbarSelectColor {
    return UIColor.whiteColor;
}

+ (nonnull UIColor *)tj_presentMaskColor {
    return [[UIColor blackColor] colorWithAlphaComponent:0.5];
}

+ (nonnull CGColorRef)tj_borderColor {
    return UIColorMake(0xdadada).CGColor;
}

+ (nonnull UIColor *)tj_placeholderTextColor {
    return UIColor.tj_8D9298Color;
}

+ (nonnull UIColor *)tj_cellBackgroundColor {
    return UIColorMake(0xF2F2F2);
}

+ (nonnull UIColor *)tj_cursorColor {
    return UIColor.whiteColor;
}

+ (nonnull UIColor *)tj_F7F8FAColor {
    return UIColorMake(0xF7F8FA);
}

+ (nonnull UIColor *)tj_1E1F23Color {
    return UIColorMake(0x1E1F23);
}

+ (nonnull UIColor *)tj_randomColor {
    u_int8_t red = arc4random_uniform(256);
    u_int8_t green = arc4random_uniform(256);
    u_int8_t blue = arc4random_uniform(256);
    
    return [UIColor tj_colorWithRed:red green:green blue:blue];
}

+ (nonnull UIColor *)tj_colorWithRed:(u_int8_t)red green:(u_int8_t)green blue:(u_int8_t)blue {
    return [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:1.0];
}


+ (UIColor *)tj_colorWithHexString:(NSString *)hexColor {
    NSString * cString = [[hexColor stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    // String should be 6 or 8 characters
    if ([cString length] < 6) return [UIColor blackColor];
    // strip 0X if it appears
    if ([cString hasPrefix:@"0X"]) cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"]) cString = [cString substringFromIndex:1];
    if ([cString length] != 6) return [UIColor blackColor];
    // Separate into r, g, b substrings
    NSRange range;
    range.location = 0;
    range.length = 2;
    NSString * rString = [cString substringWithRange:range];
    range.location = 2;
    NSString * gString = [cString substringWithRange:range];
    range.location = 4;
    NSString * bString = [cString substringWithRange:range];
    // Scan values
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    
    return [UIColor colorWithRed:((float)r / 255.0f)
                           green:((float)g / 255.0f)
                            blue:((float)b / 255.0f)
                           alpha:1];
}

+ (UIColor *)tj_colorWithHex:(int)hex {
    return [UIColor colorWithRed:((hex & 0xFF0000) >> 16) / 255.0 green:((hex & 0x00FF00) >> 8) / 255.0 blue:(hex & 0x0000FF) / 255.0 alpha:1.0];
}

- (id)mutableCopy {
    CGFloat red, green, blue, alpha;
    BOOL success = [self getRed:&red green:&green blue:&blue alpha:&alpha];
    if (success) {
        return [[UIColor alloc] initWithRed:red green:green blue:blue alpha:alpha];
    } else {
        return nil;
    }
}

- (NSString *)hexString {
    CGFloat red, green, blue;
    if ([self getRed:&red green:&green blue:&blue alpha:nil]) {
        NSString *hex = [NSString stringWithFormat:@"#%02lX%02lX%02lX", lroundf(red * 255), lroundf(green * 255), lroundf(blue * 255)];
        return hex;
    }
    return @"#000000"; // 返回黑色的16进制代码作为默认值
}



@end
